// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST = "/platform/merchant/merchant/list",
  CASCADER_LIST = "/platform/merchant/merchant/cascaderList",
  GET_BY_ID = "/platform/merchant/merchant/getById",
  UPDATE = "/platform/merchant/merchant/update",
  ADD = "/platform/merchant/merchant/add",
  DELETE = "/platform/merchant/merchant/deleteById",
  BATCH_DELETE = "/platform/merchant/merchant/batchDelete",
  UPDATE_STATE = "/platform/merchant/merchant/updateStatus",
  UPDATE_SPREAD = "/platform/merchant/merchant/updateSpread",
  LIST_ROUTERS = "/platform/merchant/merchant/listRouters",
  LIST_MENU_NORMAL = "/platform/merchant/merchant/listMenuNormal",
  LIST_MENUIDS_BY_ROLEID = "/platform/merchant/listMenuIdsByRoleId",
  SAVE_ROLE_MENU = "/platform/merchant/allocationMenu",
  LIST_MENUIDS_BY_MERID = "/platform/merchant/listMenuIdsByMerId",
  RENEWAL_RECORD = "/platform/merchant/renewalRecord",
  RENEWAL = "/platform/merchant/renewal"
}

// 多条件进行查询
export const listPage = (params: any) => {
  return koi.get(API.LIST, params);
};

export const renewalRecordList = (params: any) => {
  return koi.get(API.RENEWAL_RECORD, params);
};

// 菜单级联下拉框
export const cascaderList = () => {
  return koi.get(API.CASCADER_LIST);
};

// 根据ID进行查询
export const getById = (id: any) => {
  return koi.get(API.GET_BY_ID, { id });
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

// 删除
export const deleteById = (id: any) => {
  return koi.post(API.DELETE, { id });
};

// 批量删除
export const batchDelete = (ids: any) => {
  return koi.post(API.BATCH_DELETE, { ids }); // 第一种传参方式
};

// 修改状态
export const updateStatus = (id: any, status: any) => {
  return koi.post(API.UPDATE_STATE, { id, status }); // 第一种传参方式
};

// 修改状态
export const updateSpread = (id: any, spread: any) => {
  return koi.post(API.UPDATE_SPREAD, { id, spread }); // 第一种传参方式
};

// 获取用户左侧菜单数据
export const listRouters = (id: any) => {
  return koi.get(API.LIST_ROUTERS, { id });
};

// 获取正常所有菜单数据
export const listMenuNormal = () => {
  return koi.get(API.LIST_MENU_NORMAL);
};

export const listMenuIdsByRoleId = (id: any) => {
  return koi.get(API.LIST_MENUIDS_BY_ROLEID, { id });
};

export const listMenuIdsByMerId = (tenant_id: any) => {
  return koi.get(API.LIST_MENUIDS_BY_MERID, { tenant_id });
};

export function saveMerMenu(tenantId: any, menuIds: any) {
  return koi.post(API.SAVE_ROLE_MENU, { tenantId, menuIds });
}
export function renewal(data: any) {
  return koi.post(API.RENEWAL, data);
}
